Use case: NVIC configuration

These sequences demonstrate the change in the NVIC priority setting configuration.

Sequence diagram

NVIC configuration

  @startuml

  group Configure NVIC
  "User Application"->"Cortex Driver" : HAL_NVIC_SetPriorityGrouping()
  "User Application"->"Cortex Driver" : HAL_NVIC_SetPriority()
  "User Application"->"Cortex Driver" : HAL_NVIC_EnableIRQ()
  end

  @enduml

Code snippet

This use case demonstrates how to set a priority for a selected IRQ using NVIC functions in HAL1 compared to HAL2.

HAL1

HAL2

HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
HAL_NVIC_SetPriority(EXTI2_IRQn, 8, 1);

HAL_NVIC_EnableIRQ(EXTI2_IRQn);
HAL_CORTEX_NVIC_SetPriorityGrouping(HAL_CORTEX_NVIC_PRIORITY_GROUP_0);
HAL_CORTEX_NVIC_SetPriority(EXTI2_IRQn,
                            HAL_CORTEX_NVIC_PREEMP_PRIORITY_8,
                            HAL_CORTEX_NVIC_SUB_PRIORITY_1);
HAL_CORTEX_NVIC_EnableIRQ(EXTI2_IRQn);

Key changes

  1. In HAL2, NVIC configuration APIs are renamed with the HAL_CORTEX_ prefix.

  2. In HAL2, priority grouping and priority values use HAL CORTEX-specific constants.